#include "gtkentry.h"
#include "gtkentryprivate.h"
#include "gtkintl.h"
-#include "gtktoolbar.h"
-#include "gtktoolitem.h"
#include "gtkstylecontext.h"
#include "gtksearchbar.h"
typedef struct {
/* Template widgets */
GtkWidget *revealer;
- GtkWidget *toolbar;
+ GtkWidget *tool_box;
GtkWidget *box_center;
GtkWidget *close_button;
/* When constructing the widget, we want the revealer to be added
* as the first child of the search bar, as an implementation detail.
* After that, the child added by the application should be added
- * to the toolbar's box_center.
+ * to box_center.
*/
if (priv->box_center == NULL)
{
G_OBJECT_CLASS (gtk_search_bar_parent_class)->dispose (object);
}
+static gboolean
+gtk_search_bar_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ gint width, height;
+ GtkStyleContext *context;
+
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_render_background (context, cr, 0, 0, width, height);
+ gtk_render_frame (context, cr, 0, 0, width, height);
+
+ GTK_WIDGET_CLASS (gtk_search_bar_parent_class)->draw (widget, cr);
+
+ return FALSE;
+}
+
static void
gtk_search_bar_class_init (GtkSearchBarClass *klass)
{
object_class->dispose = gtk_search_bar_dispose;
object_class->set_property = gtk_search_bar_set_property;
object_class->get_property = gtk_search_bar_get_property;
+ widget_class->draw = gtk_search_bar_draw;
container_class->add = gtk_search_bar_add;
g_object_class_install_properties (object_class, LAST_PROPERTY, widget_props);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/gtksearchbar.ui");
- gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, toolbar);
+ gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, tool_box);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, revealer);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, box_center);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, close_button);
gtk_search_bar_init (GtkSearchBar *bar)
{
GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
+ GtkStyleContext *context;
gtk_widget_init_template (GTK_WIDGET (bar));
- gtk_widget_show_all (priv->toolbar);
+ gtk_widget_show_all (priv->tool_box);
g_signal_connect (priv->revealer, "notify::reveal-child",
G_CALLBACK (reveal_child_changed_cb), bar);
gtk_widget_set_no_show_all (priv->close_button, TRUE);
g_signal_connect (priv->close_button, "clicked",
G_CALLBACK (close_button_clicked_cb), bar);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (bar));
+ gtk_style_context_add_class (context, "search-bar");
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+
};
/**
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="vexpand">False</property>
<property name="hexpand">True</property>
+ <property name="vexpand">False</property>
<child>
- <object class="GtkToolbar" id="toolbar">
+ <object class="GtkBox" id="tool_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <style>
- <class name="primary-toolbar"/>
- </style>
+ <property name="border_width">5</property>
+ <child>
+ <object class="GtkBox" id="box_left">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box_center">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
<child>
- <object class="GtkToolItem" id="tool_item">
+ <object class="GtkBox" id="box_right">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkBox" id="tool_box">
+ <object class="GtkButton" id="close_button">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkBox" id="box_left">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="box_center">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="halign">center</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="relief">none</property>
+ <style>
+ <class name="raised"/>
+ <class name="close"/>
+ </style>
<child>
- <object class="GtkBox" id="box_right">
+ <object class="GtkImage" id="close_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="halign">end</property>
- <property name="hexpand">True</property>
- <child>
- <object class="GtkButton" id="close_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
- <style>
- <class name="raised"/>
- <class name="close"/>
- </style>
- <child>
- <object class="GtkImage" id="close_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">window-close-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="icon_name">window-close-symbolic</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
</packing>
</child>
</object>